home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / share / audacity / plug-ins / rissetdrum.ny < prev    next >
Encoding:
Audacity Nyquits plug-in  |  2010-09-21  |  2.3 KB  |  127 lines

  1. ;nyquist plug-in
  2.  
  3. ;version 3
  4.  
  5. ;type generate
  6.  
  7. ;categories "http://lv2plug.in/ns/lv2core#GeneratorPlugin"
  8.  
  9. ;name "Risset Drum..."
  10.  
  11. ;action "Generating Risset Drum..."
  12.  
  13. ;info "Risset Drum generator by Steven Jones, after Jean Claude Risset\nReleased under terms of the GNU General Public License version 2\nProduces a realistic drum sound consisting of three components;\na sine wave ring-modulated by narrow band noise, an enharmonic\ntone, and a relatively strong sine wave at the fundamental"
  14.  
  15.  
  16.  
  17. ;control frq "Frequency [Hz]" real "" 100 50 2000
  18.  
  19. ;control decay "Decay [seconds]" real "" 2 0.125 10
  20.  
  21. ;control cf "Center frequency of noise [Hz]" real "" 500 100 5000
  22.  
  23. ;control bw "Width of noise band [Hz]" real "" 400 10 1000
  24.  
  25. ;control noise "Amount of noise in mix [percent]" real "" 50 0 100
  26.  
  27.  
  28.  
  29. (if (not (boundp '*rdrum-wtabsize*))
  30.  
  31.     (progn
  32.  
  33.       (setq *rdrum-wtabsize*  2048)
  34.  
  35.       (setq *rdrum-wtab* 
  36.  
  37.      (list (sum
  38.  
  39.           (scale 1.00 (build-harmonic 10 *rdrum-wtabsize*))
  40.  
  41.           (scale 1.50 (build-harmonic 16 *rdrum-wtabsize*))
  42.  
  43.           (scale 2.00 (build-harmonic 22 *rdrum-wtabsize*))
  44.  
  45.           (scale 1.50 (build-harmonic 23 *rdrum-wtabsize*)))
  46.  
  47.              (hz-to-step 1) t))))
  48.  
  49.  
  50.  
  51.  
  52.  
  53. (defun log2 (n)
  54.  
  55.   (/ (log (float n))(log 2.0)))
  56.  
  57.  
  58.  
  59.  
  60.  
  61. (defun percussion (decay)
  62.  
  63.   (let* ((half-life (expt 2.0 (- (log2 decay) 3))))
  64.  
  65.     (exp-dec 0 half-life decay)))
  66.  
  67.  
  68.  
  69.  
  70.  
  71. (defun pink (dur cutoff)
  72.  
  73.   (lowpass6 (noise dur) cutoff))
  74.  
  75.   
  76.  
  77.  
  78.  
  79. (defun risset-drum (frq decay cf bw noise)
  80.  
  81.   (let* ((decay2 (* decay 0.50))
  82.  
  83.       (pitch1 (hz-to-step frq))
  84.  
  85.       (pitch2 (hz-to-step (* frq 0.10)))
  86.  
  87.       (noise-mix  (float (min (max (/ noise 100) 0) 1)))
  88.  
  89.       (tone-mix   (- 1 noise-mix)))
  90.  
  91.     (sum (mult 
  92.  
  93.        (sum (scale noise-mix 
  94.  
  95.                (mult (sine (hz-to-step cf) decay2)
  96.  
  97.                      (pink decay2 bw)))
  98.  
  99.             (scale (* tone-mix 0.17)
  100.  
  101.                       (osc pitch2 decay2 *rdrum-wtab*)))
  102.  
  103.        (percussion decay2))
  104.  
  105.       (mult (scale tone-mix (sine pitch1 decay))
  106.  
  107.                (percussion decay)))))
  108.  
  109.       
  110.  
  111.  
  112.  
  113. ;; Generate signal and normalize.
  114.  
  115. ;; ISSUE: Is there any way to normalize signal without 
  116.  
  117. ;; generating it twice?
  118.  
  119. ;;
  120.  
  121. (setf peakval (peak (risset-drum frq decay cf bw (/ noise 100))
  122.  
  123. ny:all))
  124.  
  125. (scale (/ 0.8 peakval)(risset-drum frq decay cf bw (/ noise 100)))
  126.  
  127.